#include <container.h>

#include <widget.h>

namespace lgb_gtk
{

  int Container::AddChild(Widget *widget = NULL)
  {
    if( NULL == widget )
      return 1;

    if(Contains(widget))
      return 2;

    widget->AddTo(canvasForChild);
    childens.push_back(widget);
    return 0;
  }

  int Container::RemoveChild(Widget *widget = NULL)
  {
    if( NULL == widget )
      return 1;

    widget->Alone();
    childens.remove(widget);
    return 0;
  }

  bool Container::Contains(Widget *widget)
  {
    std::list<Widget*>::iterator it;
    for(it = childens.begin() ; it != childens.end() ; it ++)
      if(*it == widget)
	return true;
    return false;
  }

}
